<?php defined('IN_NWIDC') or exit('Access Invalid!');?>
<link rel="stylesheet" type="text/css" href="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/themes/ui-lightness/jquery.ui.css"  />

<script src='/data/resource/layer/layer.js'></script>
<link rel="stylesheet" href="/static/webuploader/webuploader.css">
<script src='/static/webuploader/webuploader.js'></script>

<style>
  #profile_form input[type="text"]{
    width: 200px;
  }
</style>

<div class="wrap">
  <div class="tabmenu">
    <?php include template('layout/submenu');?>
  </div>
  <div class="ncm-user-profile" style="overflow: hidden;">
    <div class="user-avatar"><span><img src="<?php echo getMemberAvatar($output['member_info']['member_avatar']);?>"></span></div>
    <div class="ncm-default-form fr">
      <form method="post" id="profile_form" action="index.php?act=member_information&op=member">
        <input type="hidden" name="form_submit" value="ok" />
        <input type="hidden" name="old_member_avatar" value="<?php echo $output['member_info']['member_avatar']; ?>" />
        <dl>
          <dt><?php echo $lang['home_member_username'].$lang['nc_colon'];?></dt>
          <dd>
              <span class="w400"><?php echo $output['member_info']['member_name']; ?>&nbsp;&nbsp;
              <?php if ($output['member_info']['level_name']){ ?>
              <div class="nc-grade-mini" style="cursor:pointer;" onclick="javascript:;"><?php echo $output['member_info']['level_name'];?></div>
              <?php } ?>
              </span>
              <!-- <span>&nbsp;&nbsp;<?php echo $lang['home_member_privacy_set'];?></span> -->
         </dd>
        </dl>
        <dl>
          <dt><?php echo $lang['home_member_email'].$lang['nc_colon'];?></dt>
          <dd><span class="w400"><?php echo $output['member_info']['member_email']; ?>&nbsp;&nbsp;
            <?php if ($output['member_info']['member_email_bind'] == '1') { ?>
            <a href="index.php?act=member_security&op=auth&type=modify_email">更换邮箱</a>
            <?php } else { ?>
            <a href="index.php?act=member_security&op=auth&type=modify_email">绑定邮箱</a>
            <?php } ?></span><!-- <span>
            <select name="privacy[email]">
              <option value="0" <?php if($output['member_info']['member_privacy']['email'] == 0){?>selected="selected"<?php }?>><?php echo $lang['home_member_public'];?></option>
              <option value="1" <?php if($output['member_info']['member_privacy']['email'] == 1){?>selected="selected"<?php }?>><?php echo $lang['home_member_friend'];?></option>
              <option value="2" <?php if($output['member_info']['member_privacy']['email'] == 2){?>selected="selected"<?php }?>><?php echo $lang['home_member_privary']?></option>
            </select>
            </span> -->
          </dd>
        </dl>
        <dl>
          <dt><?php echo $lang['home_member_truename'].$lang['nc_colon'];?></dt>
          <dd><span class="w400">
            <input type="text" class="text" maxlength="20" name="member_truename" value="<?php echo $output['member_info']['member_truename']; ?>" />
            </span><!-- <span>
            <select name="privacy[truename]">
              <option value="0" <?php if($output['member_info']['member_privacy']['truename'] == 0){?>selected="selected"<?php }?>><?php echo $lang['home_member_public'];?></option>
              <option value="1" <?php if($output['member_info']['member_privacy']['truename'] == 1){?>selected="selected"<?php }?>><?php echo $lang['home_member_friend'];?></option>
              <option value="2" <?php if($output['member_info']['member_privacy']['truename'] == 2){?>selected="selected"<?php }?>><?php echo $lang['home_member_privary']?></option>
            </select>
            </span> --></dd>
        </dl>
        <dl>
          <dt><?php echo $lang['home_member_sex'].$lang['nc_colon'];?></dt>
          <dd><span class="w400">
            <label>
              <input type="radio" name="member_sex" value="3" <?php if($output['member_info']['member_sex']==3 or ($output['member_info']['member_sex']!=2 and $output['member_info']['member_sex']!=1)) { ?>checked="checked"<?php } ?> />
              <?php echo $lang['home_member_secret'];?></label>
            &nbsp;&nbsp;
            <label>
              <input type="radio" name="member_sex" value="2" <?php if($output['member_info']['member_sex']==2) { ?>checked="checked"<?php } ?> />
              <?php echo $lang['home_member_female'];?></label>
            &nbsp;&nbsp;
            <label>
              <input type="radio" name="member_sex" value="1" <?php if($output['member_info']['member_sex']==1) { ?>checked="checked"<?php } ?> />
              <?php echo $lang['home_member_male'];?></label>
            </span><!-- <span>
            <select name="privacy[sex]">
              <option value="0" <?php if($output['member_info']['member_privacy']['sex'] == 0){?>selected="selected"<?php }?>><?php echo $lang['home_member_public'];?></option>
              <option value="1" <?php if($output['member_info']['member_privacy']['sex'] == 1){?>selected="selected"<?php }?>><?php echo $lang['home_member_friend'];?></option>
              <option value="2" <?php if($output['member_info']['member_privacy']['sex'] == 2){?>selected="selected"<?php }?>><?php echo $lang['home_member_privary']?></option>
            </select>
            </span> --></dd>
        </dl>
        <dl>
          <dt><?php echo $lang['home_member_birthday'].$lang['nc_colon'];?></dt>
          <dd><span class="w400">
            <input type="text" class="text" name="birthday" maxlength="10" id="birthday" value="<?php echo $output['member_info']['member_birthday']; ?>" />
            </span><!-- <span>
            <select name="privacy[birthday]">
              <option value="0" <?php if($output['member_info']['member_privacy']['birthday'] == 0){?>selected="selected"<?php }?>><?php echo $lang['home_member_public'];?></option>
              <option value="1" <?php if($output['member_info']['member_privacy']['birthday'] == 1){?>selected="selected"<?php }?>><?php echo $lang['home_member_friend'];?></option>
              <option value="2" <?php if($output['member_info']['member_privacy']['birthday'] == 2){?>selected="selected"<?php }?>><?php echo $lang['home_member_privary']?></option>
            </select>
            </span> --></dd>
        </dl>
        <dl>
          <dt><?php echo $lang['home_member_areainfo'].$lang['nc_colon'];?></dt>
          <dd><span id="region" class="w400">
            <input type="hidden" value="<?php echo $output['member_info']['member_provinceid'];?>" name="province_id" id="province_id">
            <input type="hidden" value="<?php echo $output['member_info']['member_cityid'];?>" name="city_id" id="city_id">
            <input type="hidden" value="<?php echo $output['member_info']['member_areaid'];?>" name="area_id" id="area_id" class="area_ids" />
            <input type="hidden" value="<?php echo $output['member_info']['member_areainfo'];?>" name="area_info" id="area_info" class="area_names" />
            <?php if(!empty($output['member_info']['member_areaid'])){?>
            <span><?php echo $output['member_info']['member_areainfo'];?></span>
            <input type="button" value="<?php echo $lang['nc_edit'];?>" style="background-color: #F5F5F5; width: 60px; height: 32px; border: solid 1px #E7E7E7; cursor: pointer" class="edit_region" />
            <select style="display:none;">
            </select>
            <?php }else{?>
            <select>
            </select>
            <?php }?>
            </span><!-- <span>
            <select name="privacy[area]">
              <option value="0" <?php if($output['member_info']['member_privacy']['area'] == 0){?>selected="selected"<?php }?>><?php echo $lang['home_member_public'];?></option>
              <option value="1" <?php if($output['member_info']['member_privacy']['area'] == 1){?>selected="selected"<?php }?>><?php echo $lang['home_member_friend'];?></option>
              <option value="2" <?php if($output['member_info']['member_privacy']['area'] == 2){?>selected="selected"<?php }?>><?php echo $lang['home_member_privary']?></option>
            </select>
            </span> --></dd>
        </dl>
        <dl>
          <dt>QQ<?php echo $lang['nc_colon'];?></dt>
          <dd><span class="w400">
            <input type="text" class="text" maxlength="30" name="member_qq" value="<?php echo $output['member_info']['member_qq']; ?>" />
            </span><!-- <span>
            <select name="privacy[qq]">
              <option value="0" <?php if($output['member_info']['member_privacy']['qq'] == 0){?>selected="selected"<?php }?>><?php echo $lang['home_member_public'];?></option>
              <option value="1" <?php if($output['member_info']['member_privacy']['qq'] == 1){?>selected="selected"<?php }?>><?php echo $lang['home_member_friend'];?></option>
              <option value="2" <?php if($output['member_info']['member_privacy']['qq'] == 2){?>selected="selected"<?php }?>><?php echo $lang['home_member_privary']?></option>
            </select>
            </span>  --></dd>
        </dl>
        <dl>
          <dt><?php echo $lang['home_member_wangwang'].$lang['nc_colon'];?></dt>
          <dd><span class="w400">
            <input name="member_ww" type="text" class="text" maxlength="50" id="member_ww" value="<?php echo $output['member_info']['member_ww'];?>" />
            </span><!-- <span>
            <select name="privacy[ww]">
              <option value="0" <?php if($output['member_info']['member_privacy']['ww'] == 0){?>selected="selected"<?php }?>><?php echo $lang['home_member_public'];?></option>
              <option value="1" <?php if($output['member_info']['member_privacy']['ww'] == 1){?>selected="selected"<?php }?>><?php echo $lang['home_member_friend'];?></option>
              <option value="2" <?php if($output['member_info']['member_privacy']['ww'] == 2){?>selected="selected"<?php }?>><?php echo $lang['home_member_privary']?></option>
            </select>
            </span> --></dd>
        </dl>
        <style>
        .webuploader-pick{
          margin-top: 10px;
          background: none;
          color: #aaa;
        }
        .webuploader-pick{
          margin-top: 0;
          width: 240px;
          height: 150px;
          padding: 0;
        }
        .real .button{
          display: inline-block;
          margin-right: 10px;
          width: 240px;
          height: 150px;
          background: #f7f7f7;
          border : 1px solid #ddd;
          box-shadow: 2px 2px 2px #ddd;
          font-size: 15px;
          font-family: 'Microsoft Yahei';
          padding: 0;
          text-align: center;
          line-height: 150px;

        }
        .real .button img{
          width: 240px;
          height: 150px;
          float: left;
        }
        </style>
        <?php
          $m = Model('member');
          $uinfo = $m->find($_SESSION['member_id']);
        ?>
        <dl>
          <dt>身份证号信息：</dt>
          <dd>
            <span class="w800">
              <input type="text" class="text" maxlength="18" name="idcard" value="<?php echo $uinfo[idcard]?>">
              
            </span>
            
            <style>
            .layui-layer-tips{
              width: auto !important;
            }
            </style>
            <script>
              layer.tips("请上传真实身份信息，以便海关查验",'[name=idcard]',{time:0})
            </script>
          </dd>
        </dl>
        <dl class='real'>
          <dt>
            身份证照片：
          </dt>
          <dd>
            <div>
              <?php
                
                if($uinfo['is_buy'] == 1){
              ?>
              <!-- <p style='color:red'>已通过</p> -->
              <?php
                }
                else{
              ?>
              <!-- <p style='color:#999'>未通过</p> -->
              <?php    
                }
              ?>
              
              <!-- <div style='height: 10px;clear: both;'> -->
              <!-- </div> -->
              <input type="hidden" name='zpic' value='<?php echo $uinfo[zpic]?>'>
              <input type="hidden" name='fpic' value='<?php echo $uinfo[fpic]?>'>

              <div class='button'>
                <?php
                  if(!empty($uinfo['zpic'])){
                ?>
                <img src='<?php echo $uinfo['zpic']?>' />
                <?php    
                  }else{
                ?>
                请点击上传身份证正面照片
                <?php
                  }
                ?>
              </div>
              <div class='button'>
                <?php
                  if(!empty($uinfo['fpic'])){
                ?>
                <img src='<?php echo $uinfo['fpic']?>' />
                <?php    
                  }else{
                ?>
                请点击上传身份证反面照片
                <?php
                  }
                ?>
                
              </div>
            </div>
          </dd>
        </dl>
        <script>
          var BASE_URL = '/static/webuploader';
          var zuploader = WebUploader.create({
            
              // swf文件路径
              swf: BASE_URL + '/Uploader.swf',
              // 文件接收服务端。
              server: '/static/webuploader/fileupload.php',
              // 选择文件的按钮。可选。
              // 内部根据当前运行是创建，可能是input元素，也可能是flash.
              pick: '.real .button:eq(0)',
              // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
              resize: false,

            auto : true,
            
              accept: {
                  title: 'Images',
                  extensions: 'gif,jpg,jpeg,bmp,png',
                  mimeTypes: 'image/*'
              }
          });
          zuploader.on( 'fileQueued', function( file ) {
            $('.real .button:eq(0)').find('.webuploader-pick').html('上传中，请稍后......');
          });
          zuploader.on( 'uploadSuccess', function( file , response ) {
            $('[name=zpic]').val('/static/webuploader/' + response.result);
            $('.real .button:eq(0)').find('.webuploader-pick').html(
              '<img src="/static/webuploader/' + response.result + '">'
            );
          });
          zuploader.on( 'uploadError', function( file ) {
              alert('上传出错！');
              $('.real .button:eq(0)').find('.webuploader-pick').html("请点击上传身份证正面照片");
          });
          var fuploader = WebUploader.create({
            
              // swf文件路径
              swf: BASE_URL + '/Uploader.swf',
              // 文件接收服务端。
              server: '/static/webuploader/fileupload.php',
              // 选择文件的按钮。可选。
              // 内部根据当前运行是创建，可能是input元素，也可能是flash.
              pick: '.real .button:eq(1)',
              // 不压缩image, 默认如果是jpeg，文件上传前会压缩一把再上传！
              resize: false,

            auto : true,
            
              accept: {
                  title: 'Images',
                  extensions: 'gif,jpg,jpeg,bmp,png',
                  mimeTypes: 'image/*'
              }
          });
          fuploader.on( 'fileQueued', function( file ) {
            $('.real .button:eq(1)').find('.webuploader-pick').html('上传中，请稍后......');
          });
          fuploader.on( 'uploadSuccess', function( file , response ) {
            $('[name=fpic]').val('/static/webuploader/' + response.result);
            $('.real .button:eq(1)').find('.webuploader-pick').html(
              '<img src="/static/webuploader/' + response.result + '">'
            );
          });
          fuploader.on( 'uploadError', function( file ) {
              alert('上传出错！');
              $('.real .button:eq(1)').find('.webuploader-pick').html("请点击上传身份证正面照片");
          });
        </script>
<!--        <dl>-->
<!--          <dt>-->
<!--            上级代理：-->
<!--          </dt>-->
<!--          <dd>-->
<!--            <span class="w400">-->
<!--              --><?php
//                $m = Model();
//                $info = $m->table('proxy')->where(array(
//                  'member_id' => $_SESSION['member_id']
//                ))->find();
//                if(count($info)){
//                  if($info['parent_id'] == 0){
//                    echo '金牌代理商';
//                  }
//                  else{
//                    $user = Model('member');
//                    $parent_info = $user->where(array("member_id" => $info['parent_id']))->find();
//                    echo $parent_info['member_name'];
//                  }
//
//                }
//                else{
//              ?>
<!--              <style>-->
<!--                ._btn{-->
<!--                  color: #fff;-->
<!--                  width: 100px;-->
<!--                  display: block;-->
<!--                  line-height: 25px;-->
<!--                  background: #14B0E3;-->
<!--                  text-align: center;-->
<!--                  border:1px solid rgba(20,176,227,.3);-->
<!--                }-->
<!--                ._btn:hover{-->
<!--                  text-decoration: none;-->
<!--                  background: rgba(20,176,227,.8);-->
<!--                  color: #fff;-->
<!--                }-->
<!--              </style>-->
<!--              <a href="/shop/index.php?act=seccode&op=proxy_list" class='_btn'>申请代理</a>-->
<!--              <script>-->
<!--                $('._btn').click(function(event) {-->
<!--                  layer.open({-->
<!--                    type: 2,-->
<!--                    title: false,-->
<!--                    area : ['800px','680px'],-->
<!--                    skin: 'layui-layer-rim',-->
<!--                    scrollbar  : false,-->
<!--                    content: '' -->
<!--                  });-->
<!--                });-->
<!--              </script>-->
<!--              --><?php
//                }
//              ?>
<!--            </span>-->
<!--          </dd>-->
<!--        </dl>-->
        <dl class="bottom">
          <dt></dt>
          <dd>
            <label class="submit-border">
              <input type="submit" class="submit" value="<?php echo $lang['home_member_save_modify'];?>" />
            </label>
          </dd>
        </dl>
      </form>
    </div>
  </div>
</div>
<script type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/common_select.js" charset="utf-8"></script> 
<script type="text/javascript">
//注册表单验证
$(function(){
	regionInit("region");
	$('#birthday').datepicker({dateFormat: 'yy-mm-dd'});
    $('#profile_form').validate({
    	submitHandler:function(form){
    		if ($('select[class="valid"]').eq(0).val()>0) $('#province_id').val($('select[class="valid"]').eq(0).val());
			if ($('select[class="valid"]').eq(1).val()>0) $('#city_id').val($('select[class="valid"]').eq(1).val());
			ajaxpost('profile_form', '', '', 'onerror')
		},
        rules : {
            member_truename : {
				minlength : 2,
                maxlength : 20
            },
            member_qq : {
				digits  : true,
                minlength : 5,
                maxlength : 12
            }
        },
        messages : {
            member_truename : {
				minlength : '<?php echo $lang['home_member_username_range'];?>',
                maxlength : '<?php echo $lang['home_member_username_range'];?>'
            },
            member_qq  : {
				digits    : '<?php echo $lang['home_member_input_qq'];?>',
                minlength : '<?php echo $lang['home_member_input_qq'];?>',
                maxlength : '<?php echo $lang['home_member_input_qq'];?>'
            }
        }
    });
});


$('.submit-border .submit').click(function(){
  var idcard = $('[name=idcard]').val();
  if(idcard != ''){
    if(!/^[0-9xX]{15}|[0-9xX]{18}$/.test(idcard)){
      layer.msg('请输入正确的身份证号码！');
      return false;
    }
  }
});
</script> 
<script charset="utf-8" type="text/javascript" src="<?php echo RESOURCE_SITE_URL;?>/js/jquery-ui/i18n/zh-CN.js" ></script>